package com.wutianyi.session;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import javax.servlet.http.HttpSession;

import org.apache.commons.lang.StringUtils;

import com.wutianyi.web.wrapper.MyHttpSession;

public class HttpSessionFactory {

	private static Map<String, MyHttpSession> caches = new HashMap<String, MyHttpSession>();

	public static HttpSession getHttpSession(String sessionId) {

		if (StringUtils.isBlank(sessionId) || !caches.containsKey(sessionId)) {
			UUID uuid = UUID.randomUUID();
			sessionId = uuid.toString();
			MyHttpSession session = new MyHttpSession(sessionId);
			caches.put(sessionId, session);
		}

		return caches.get(sessionId);
	}
}
